
/**
 * Attribute associated with a function symbol. In addition to the name,
 * this class has a label attribute. The label associated to a function is the 
 * 3a name in CALL and the address in 3a code function definition.
 * @author MLB
 *
 */
public class FunctionAttribute extends GenericAttribute{
    public String name;
    public LabelAttribute label;

    /**
     * Constructor
     * @param n String: the name of the function in VSL+ code
     * @param lab LabelAttribute: the label associated
     * @param t : a function type handled separately in compilation process
     */
    public FunctionAttribute(String n, LabelAttribute lab, FunctionType t){
    	super(t);
    	name = n;
    	label = lab;
    }
    /**
     * The scope of a function is always zero in VSL+
     */
	public int getScope() {
		return 0;
	}
    
	/**
	 * Function may be declared but undefined (proto) or defined and consequently
	 * declared. This function is used to change this status in the function name attributes.
	 * The attribute proto in type can be used to check if all declared functions are defined.
	 */
	public void setFunction(){
		((FunctionType)type).proto2function();
	}
	
	/**
	 * Check if it is only declared
	 * @return boolean
	 */
	public boolean isPrototype(){
		return ((FunctionType)type).isProto();
	}
	
	/**
	 * Necessary for TAC printing
	 */
    public String getName3a(){
    	return name;
    }
}